import request from '../service/service';

/**
 * 获取用户信息
 */
export function getUserList(data) {
  return request({
    protocol: 'bus/user/findPage',
    options: data,
    method: 'get',
  });
}

/**
 * 用户数据导出
 */
export function downLoadUsers(data) {
  return request({
    protocol: 'bus/user/downLoadXlsByJxl',
    options: data,
    method: 'get',
  });
}

/**
 * 用户新增/修改
 */
export function setUserInfo(data) {
  return request({
    protocol: 'bus/user/set',
    options: data,
    method: 'post',
  });
}

/**
 * 修改密码
 */
export function updatePassword(data) {
  return request({
    protocol: 'bus/user/update-password',
    options: data,
    method: 'post',
    hasQuery: true
  });
}

/**
 * 根据用户id获取用户信息
 */
export function getUserInfoById(data) {
  return request({
    protocol: '/bus/user/getUserInfoById',
    options: data,
    method: 'get',
  });
}

/**
 * 根据用户获取项目列表
 */
export function getUserProject(data) {
  return request({
    protocol: '/bus/user/getProjectList',
    options: data,
    method: 'get',
  });
}

/**
 * 获取用户导入模板
 */
export function getUserUploadTmp(data) {
  return request({
    protocol: '/bus/user/getUploadTemplate',
    options: data,
    method: 'get',
  });
}

/**
 * 用户数据导入
 */
export function getUserTmpUpload(data) {
  return request({
    protocol: '/bus/user/uploadExcel',
    options: data,
    method: 'formData',
    requestConfig: {
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
      }
    }
  });
}

/**
 * 用户批量添加/删除项目
 */
export function setUserProjectList(data) {
  return request({
    protocol: '/bus/user/set-userProjectList',
    options: data,
    method: 'post',
    hasQuery: true
  });
}

/**
 * 根据用户id获取用户归属机构
 */
export function getOrgTreeByUser(data) {
  return request({
    protocol: '/bus/user/getOrgTree',
    options: data,
    method: 'get',
  });
}

/**
 * 更新用户项目角色是否可用
 */
export function setEnAbleFlag(data) {
  return request({
    protocol: '/bus/user/setEnAbleFlag',
    options: data,
    method: 'get',
  });
}

/**
 * 删除用户
 */
export function delUser(data) {
  return request({
    protocol: '/bus/user/delByUserId',
    options: data,
    method: 'get',
  });
}

/**
 * 用户关联机构
 */
export function userRelationOrg(data) {
  return request({
    protocol: '/bus/user/relationOrg',
    options: data,
    method: 'get',
  });
}
